package com.houserent.controller;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.houserent.entry.HouseResult;
import com.houserent.service.HouseService;

@Controller
@RequestMapping("/house")
public class HouseController {

    @Resource
    private HouseService house;

    @ResponseBody
    @RequestMapping("/getHouseUseInfo.do")
    public HouseResult getHouseUseInfo(String userId, String allInfoTag) {
        return house.getHouseUseInfo(userId, allInfoTag);
    }

    @ResponseBody
    @RequestMapping("/addHousePic.do")
    public HouseResult addHousePic(@RequestParam("roompic") MultipartFile roompic, HttpServletRequest request,
            HttpServletResponse response) throws IOException {
        return house.addHousePic(roompic, request, response);
    }

    @ResponseBody
    @RequestMapping("/addHouse.do")
    public HouseResult addHouse(String houseId, String hostId, String roomNubmerType, String roomAddress,
            String roomType, String addressDetial, String roomnumber, String houseRent, String powerCharge,
            String waterCharge, String guarantyFee, String houseGoods) {
        return house.addHouse(houseId, hostId, roomNubmerType, roomAddress, roomType, addressDetial, roomnumber,
                houseRent, powerCharge, waterCharge, guarantyFee, houseGoods);
    }

    @ResponseBody
    @RequestMapping("/qryAllHouse.do")
    public HouseResult qryAllHouse(String userId) {
        return house.qryAllHouse(userId);
    }

    @ResponseBody
    @RequestMapping("/getUserInfo.do")
    public HouseResult getUserInfo(String userId) {
        return house.getUserInfo(userId);
    }
}
